import requests
from lxml import etree
import pandas as pd


UA="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0"

all_data = pd.DataFrame()
for page in range(1,3):
    url=f"https://www.jkl.com.cn/shopLis.aspx?current={page}&TypeId=10045"
    html=requests.get(url=url,headers={"User-Agent":UA}).text
    element=etree.HTML(html)
    name = element.xpath("//span[@class='con01']/text()")
    local = element.xpath("//span[@class='con02']/text()")
    phone = element.xpath("//span[@class='con03']/text()")
    time = element.xpath("//span[@class='con04']/text()")
    data=pd.DataFrame(
        {
            "店名":name,
            "地址":local,
            "电话":phone,
            "营业时间":time,
        }
    )
    all_data=pd.concat([all_data,data],ignore_index=True)

all_data.to_csv(
    "./file/朝阳店.csv",
    encoding="utf-8-sig",
    index=False
)